package com.hangyutech.strelitzia.utils;

import java.security.MessageDigest;

/**
 * 557 strelitzia.
 *
 * @author WiconWang <WiconWang@gmail.com>
 * @copyright 2020/12/4 3:27 PM
 */
public class EncryptUtil {

    //盐，用于混交md5
    private static final String slat = "&%5123***&&%%$$#@";

    public static String md5DigestAsHex(String dataStr) {
        try {
            dataStr = dataStr + slat;
            MessageDigest m = MessageDigest.getInstance("MD5");
            m.update(dataStr.getBytes("UTF8"));
            byte s[] = m.digest();
            StringBuilder result = new StringBuilder();
            for (int i = 0; i < s.length; i++) {
                result.append(Integer.toHexString((0x000000FF & s[i]) | 0xFFFFFF00).substring(6));
            }
            return result.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return "";
    }
}
